import React from 'react'
import { withRouter } from "react-router-dom";
class Sort extends React.Component {
    state = {
        SortData: null
    }
    goSOn = (index) => {
        console.log(index)
        console.log(this)
        this.props.history.push("/index/home/" + index)
    }
    componentDidMount() {
        this.$postData('/api/goods/getOneClassList', {}, params => {
            console.log(params)
            switch (params.code) {
                case 100:
                    this.setState({
                        SortData: params.data
                    })
                    break;
                default:
                    this.Toast.info(params.msg);
                    break;
            }
        })
    }
    render() {
        return (
            <div className='Sort'>
                {this.state.SortData ? this.state.SortData.map((val, index) => (
                    <div className='center' key={index} onClick={this.goSOn.bind(this, val.id)}>
                        <img alt='' src={val.pic}></img>
                        <p>{val.className}</p>
                    </div>
                )) : <div></div>}
            </div>
        )
    }
}
export default withRouter(Sort)